/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main.Tree;

import java.io.IOException;
import java.util.List;
import main.Resulter;

/**
 *
 * @author Pacific
 */
public class ResultsTree {
    NodeTree root ;
    
    
    public ResultsTree( Resulter resulter ) {
        root = new NodeTree( resulter ) ;
    }

    public Resulter getFinishResult() throws IOException {
        System.out.println("Start Method Branches and Borders.");
        if( root.getResulter().isResult() )
            return root.getResulter() ;
        
        
        Resulter finishResult ;
        do {
            System.out.println("In Cycle");
            NodeTree minimal = root.getResultWithMinimalBorder(0) ;
            System.out.println("Build Assumption for:\n"+minimal.getResulter());
            List<Resulter> list = minimal.getResulter().getAssumptions() ;
            for( Resulter res : list ) {
                System.out.println("Builded Assumption:\n"+res) ;
            }
            minimal.addChilds(list) ;
            finishResult = root.getFinishResult() ;
        } while( finishResult == null ) ;
        
        
        
        return finishResult ;
    }
    
    protected boolean hasResult() {
        return false ;
    }
}
